﻿using System;
using System.Collections.Generic;
 
using CarTrackr.Data;

namespace CarTrackr.Business.Services
{
    public class AppService :IAppService
    {
        private IRepository repository;

     
        public AppService(): this(new EntityFrameworkRepository())
        {
           
        }

        public AppService(IRepository repository)
        {
            this.repository = repository;
        }


        public List<User> ListUsers()
        {
            return repository.ListUsers<User>();
        }



      
        public User GetUserByName(string userName)
        {
           return  repository.GetUserByName<User>(userName); 
        }

      

        public List<Car> ListCars(Guid userId)
        {
            return repository.ListCars<Car>(userId);
        }

        public Car GetCarById(Guid id)
        {
            return repository.GetCarById<Car>(id);
        }

        public Car GetCarByLicensePlate(string licensePlate)
        {
            return repository.GetCarByLicensePlate<Car>(licensePlate);
        }

        public void   AddCar(Car car, Guid userId)
        {
            repository.AddCar(car,userId);
        }

        public void UpdateCar(Car car)
        {
            repository.UpdateCar(car);
        }

        public void RemoveCar(Guid id)
        {
            repository.RemoveCar(id);
        }



        public  List<Refuelling> ListRefuellings(Guid id)
        {
           return repository.ListRefuellings<Refuelling>(id);
        }

        public  void AddRefuelling(Refuelling refuelling,Guid carId)
        {
           repository.AddRefuelling(refuelling,carId);
        }

        public void RemoveRefuelling(Guid id)
        {
           repository.RemoveRefuelling(id);
        }


    }
}
